package com.ganlinux.pangoo.controller.restful.user;


import com.alibaba.fastjson.JSON;
import com.ganlinux.pangoo.controller.restful.base.BaseController;
import com.ganlinux.pangoo.dao.model.User;
import com.ganlinux.pangoo.entity.request.ReqFootPrintSimpleInfoList;
import com.ganlinux.pangoo.entity.request.ReqUserInfo;
import com.ganlinux.pangoo.entity.response.RspUserInfoData;
import com.ganlinux.pangoo.entity.response.base.RspBase;
import com.jfinal.aop.Before;
import com.jfinal.kit.HttpKit;

/**
 * BlogController
 * 所有 sql 与业务逻辑写在 Model 或 Service 中，不要写在 Controller 中，养成好习惯，有利于大型项目的开发与维护
 */
@Before(UserInfoInterceptor.class)
public class UserInfoController extends BaseController {
	public void save() {
		if(isCheckAccess()) {
			RspBase rspLogin = new RspBase();
			String pin = null;
			int pageindex = 1;
			int pagesize = 10;
			String jsonString = HttpKit.readData(getRequest());
			ReqFootPrintSimpleInfoList reqLogin = JSON.parseObject(jsonString, ReqFootPrintSimpleInfoList.class);
			reqLogin.setReqHeader(getHeaderFromRequest(getRequest()));

			pin = reqLogin.getReqHeader().getPin();
			RspUserInfoData rspUserInfoData = User.dao.getUserInfo(pin);
			if (rspUserInfoData == null) {
				rspLogin.setStatus(1);
				rspLogin.setMessage("失败");
			}else{
				rspLogin.setStatus(0);
				rspLogin.setData(rspUserInfoData);
				rspLogin.setMessage("成功");
			}
			renderText(JSON.toJSONString(rspLogin));
		}else{
			RspBase rspBase = new RspBase();
			rspBase.setStatus(1);
			rspBase.setMessage("身份验证失败");
			renderText(JSON.toJSONString(rspBase));
		}


	}

}


